<?php
/**
 * Created by PhpStorm.
 * User: 魏爷
 * Date: 2016/6/6
 * Time: 17:03
 */

namespace Home\Model;


class ForumModel extends BaseModel
{
    // 数据表名（不包含表前缀）
    protected $tableName        =   'forum';

    /**
     * 删除评论
     * @return boolean
    **/
    public function forumDel($forum_id){
        $res=$this->where("forum_id=$forum_id")->setField('forum_del',2);
        if($res==false){
            return false;
        }else{
            return true;
        }
    }
    /**
     * 根据feel_id查询信息
     * @return array()
    **/
    public function getByIdInfo($feel_id){
        $where=array();
        $where['feel_id']=$feel_id;
        $where['forum_del']=1;
        return $this->where($where)->order('forum_id DESC')->select();
    }
    /**
     * 添加发表
     * @return boolean
    **/
    public function forumChat($feel_id,$u_id,$forum_content){
        $data['feel_id']=$feel_id;
        $data['u_id']=$u_id;
        $data['forum_content']=$forum_content;
        $data['forum_time']=time();
        $data['forum_del']=1;
        $res=$this->add($data);
        if($res>0){
            return true;
        }else{
            return false;
        }
    }

}